optimal merge pattern with example